package com.InetAddressDemo.multicast;


import java.io.IOException;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.MulticastSocket;

/**
 *
 * 组播发送端
 * @Author weijingchen
 * @Date 2025/6/23 22:47
 * @Version 1.0.0
 */
public class Test01 {
    public static void main(String[] args) throws IOException {
        MulticastSocket multicastSocket = new MulticastSocket();
        String message = "hello world";
        byte[] bytes = message.getBytes();
        InetAddress address = InetAddress.getByName("224.0.0.1");
        int port = 8888;
        DatagramPacket dp = new DatagramPacket(bytes, bytes.length, address, port);
        multicastSocket.send(dp);
        multicastSocket.close();
    }
}
